/*****************************************************************************
*
*  PROJECT:		
*               
*  LICENSE:		
*
*  DEVELOPER:	
*
*****************************************************************************/

#include "EonTextureMgr.h"

Eon::Texture* Eon::TextureMgr::loadTexture( const char *filename )
{
	// Check the texture does not already exist.
	std::vector< Texture* >::const_iterator iter = m_Textures.begin();
	for ( ; iter != m_Textures.end(); iter++ )
	{
		Texture* pTexture = static_cast< Texture* > ( *iter );

		if ( STRING_COMPARE( pTexture->getFileName(), filename ) )
			return pTexture;
	}

	// If it doesnt exist, create it and return the ID.
	Texture* pTexture = new Texture( filename );
	m_Textures.push_back( pTexture );
	return pTexture;
}

Eon::Texture* Eon::TextureMgr::findTexture( const char *filename )
{
	std::vector< Texture* >::const_iterator iter = m_Textures.begin();
	for ( ; iter != m_Textures.end(); iter++ )
	{
		Texture* pTexture = static_cast< Texture* > ( *iter );

		if ( STRING_COMPARE( pTexture->getFileName(), filename ) )
			return pTexture;
	}

	return NULL;
}

Eon::Texture* Eon::TextureMgr::getTexture( GLuint ID )
{
	return m_Textures.at( ID );
}